package com.momo.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Fanout 模式
 *
 */
@Configuration
public class FanoutConfig {


    @Bean
    Queue queueOne(){
        return new Queue("queue_one");
    }

    @Bean
    Queue queueTwo(){
        return new Queue("queue_two");
    }

    /**
     * 创建一个FanoutExchange
     * @return
     */
    @Bean
    FanoutExchange fanoutExchange(){
        return new FanoutExchange("momo_fanout",true,false);
    }

    @Bean
    Binding bindingOne(){
        return BindingBuilder.bind(queueOne()).to(fanoutExchange());
    }

    @Bean
    Binding bindingTwo(){
        return BindingBuilder.bind(queueOne()).to(fanoutExchange());
    }
}
